//
//  HHContactUsInfoCell.m
//  HHBroker
//
//  Created by He Wei on 9/15/15.
//  Copyright © 2015 harry. All rights reserved.
//

#import "HHContactUsInfoCell.h"
#import "UIViewAdditions.h"

@interface HHContactUsInfoCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *desLabel;
@property (nonatomic, strong) UIImageView *indicatorImageView;


@end




@implementation HHContactUsInfoCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.titleLabel];
        [self addSubview:self.desLabel];
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    return self;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(HHContactUsInfoModel *)model
{
    _model = model;
    [self changeLayout];
}
- (void)changeLayout
{
    self.titleLabel.text = _model.title;
    self.desLabel.text = _model.des;

}

- (UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 120, self.frame.size.height)];
        
        titleLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
        titleLabel.font = [UIFont systemFontOfSize:14];
        titleLabel.textAlignment = NSTextAlignmentLeft;
        titleLabel.textColor = [UIColor colorWithRed:59/255.0 green:59/255.0 blue:59/255.0 alpha:1];
        titleLabel.numberOfLines = 0;
        titleLabel.backgroundColor = [UIColor whiteColor];
        titleLabel.lineBreakMode = NSLineBreakByCharWrapping;
        _titleLabel = titleLabel;
        
    }
    return _titleLabel;

}
- (UILabel *)desLabel
{
    if (_desLabel == nil) {
        UILabel *detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.right, 0, self.width-self.titleLabel.right-15-17, self.frame.size.height)];
        detailLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
        detailLabel.font = [UIFont systemFontOfSize:14];
        detailLabel.textColor = [UIColor colorWithRed:85/255.0 green:85/255.0 blue:85/255.0 alpha:1];
        detailLabel.textAlignment = NSTextAlignmentRight;
        detailLabel.numberOfLines = 0;
        detailLabel.lineBreakMode = NSLineBreakByCharWrapping;
        _desLabel = detailLabel;
    }
    return _desLabel;
}

- (UIImageView *)indicatorImageView
{
    if (_indicatorImageView == nil) {
        _indicatorImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.width-5-25, (self.height-25)/2.0, 25, 25)];
        _indicatorImageView.image = [UIImage imageNamed:@"button_kaijiao"];
        _indicatorImageView.hidden = NO;
        _indicatorImageView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleLeftMargin;
    }
    return _indicatorImageView;
}

















@end
